/**
 * Copyright 2009 University of Washington This code is released under the GPL version 3 - with a copy of the license
 * included
 * 
 * @author Maya Hao Li
 */
package seedpod.webapp.view.htmlwidget;

public class Button extends GenericHtmlWidget {
	private String				_name;
	private String				_value;
	private String				_Jscript	= "";
	private String				_type		= "button";

	public static final String	TYPE_SUBMIT	= "submit";
	public static final String	TYPE_RESET	= "reset";

	public Button(String name, String value) {
		super( name );
		_name = name;
		_value = value;
	}

	@Override
	public String render() {
		return "<input " + ATT( "type", _type ) + ATT( "value", _value ) + ATT( "name", _name ) + ATT( "class", _cssClass ) + ATT( "id", _name ) + _Jscript + ">";
	}

	public void setJscript( String jscript ) {
		_Jscript = jscript;
	}

	public void setRedirect( String newLocation ) {
		_Jscript += " onclick=\"window.location='" + newLocation + "';\" ";
	}

	public void setType( String type ) {
		_type = type;
	}
}